import urllib.request

headers = {
    'referer':'https://movie.douban.com/',
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36'
}

url = 'https://m.douban.com/rexxar/api/v2/subject/recent_hot/movie?start=0&limit=20'

req = urllib.request.Request(url,headers=headers)
resp = urllib.request.urlopen(req)


j = resp.read().decode("utf-8")
j = j.replace('true','True').replace('false','False')
d = dict(eval(j))

print(d['items'])

for x in d['items']:
    print(f"{x['title']:{x['rating']['value']}}")
